cmake_minimum_required(VERSION 3.10)

set(PROJECT_NAME mxgLog)

project(${PROJECT_NAME})

set(CMAKE_CXX_STANDARD 17)

# 添加源文件列表
file(GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# 添加boost库
set(BOOST_ROOT "D:\\repocpp\\boost_1_84_0\\gcc")
set(Boost_NO_SYSTEM_PATHS ON) # 只搜索上语句设置的搜索路径

find_package(Boost COMPONENTS regex system REQUIRED)

add_library(${PROJECT_NAME}_static STATIC ${SRC})

add_library(${PROJECT_NAME} SHARED ${SRC})

if (Boost_FOUND)
    message(STATUS "PROJECT_NAME: ${PROJECT_NAME}")
    message(STATUS "Boost found")
    message(STATUS "Boost_VERSION: ${Boost_VERSION}")
    message(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
    message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")

    include_directories(${PROJECT_SOURCE_DIR}/include ${Boost_INCLUDE_DIRS})

    target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
endif ()

set_target_properties(${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME})

set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME})

# 安装位置
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install)

# 安装静态库
install(TARGETS ${PROJECT_NAME}_static
        ARCHIVE DESTINATION lib)

# 安装动态库
install(TARGETS ${PROJECT_NAME}
        LIBRARY DESTINATION lib)

# 安装头文件
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
        DESTINATION include)
